<template>
  <div class="main-container">
    <div class="carousel-filed">
      <div class="block">
        <el-carousel height="400px">
          <el-carousel-item v-for="(item,index) in carouselItems" :key="index">
            <img class="carousel-img" :src="item.src" :alt="item.alt">
          </el-carousel-item>
        </el-carousel>
      </div>
    </div>

    <el-card class="app-filed animate__animated animate__zoomIn" shadow="never">
      <template #header>我的服务</template>
      <div class="app-grid-container">
        <div v-for="(item, index) in appEntryItems" :key="item.menuId" class="grid-item" @click="change(item.path)">
          <svg class="icon" aria-hidden="true">
            <use :href="item.icon"></use>
          </svg>
          <p>{{ item.title }}</p>
        </div>
      </div>
    </el-card>
  </div>
</template>

<script setup>
import { ref, reactive, onMounted, onUnmounted } from 'vue';
import router from "@/router/index.js";
import {getStorage} from "@/utils/localStorage.js";

/*------------------定义变量开始-------------------*/
//轮播图片对象数组
const carouselItems = [
  { src: 'https://xiaoxiaobaiyang.oss-cn-shenzhen.aliyuncs.com/student_System_img/schoolCarousel1.jpg', alt: 'Image 1' },
  { src: 'https://xiaoxiaobaiyang.oss-cn-shenzhen.aliyuncs.com/student_System_img/schoolCarousel2.jpg', alt: 'Image 2' },
  { src: 'https://xiaoxiaobaiyang.oss-cn-shenzhen.aliyuncs.com/student_System_img/schoolCarousel3.jpg', alt: 'Image 2' },
  // 更多图片...
];
//应用入口对象数组
const appEntryItems = ref([
  {
    title:"个人信息门户",
    path:"/students",
    icon:"#icon-iconsicon-grade"
  },{
    title:"数据显示中心",
    path:"/dataCenter",
    icon:"#icon-tongji"
  },{
    title:"用户管理",
    path:"/userManage",
    icon:"#icon-tuandui"
  },{
    title:"招生系统",
    path:"/recruit",
    icon:"#icon-bangongtubiaoji_bangong-caigoupingshen"
  },{
    title:"在校生报道",
    path:"/reporting",
    icon:"#icon-nenglipinggu-01"
  },{
    title:"新生入学",
    path:"/admission",
    icon:"#icon-shenhe"
  },
  {
    title:"宿舍管理",
    path:"/dormitoryManage",
    icon:"#icon-shouye2"
  },{
    title:"奖惩管理",
    path:"/RPManage",
    icon:"#icon-bangongtubiaoji_bangong-zhanshishenqing"
  },{
    title:"教材管理",
    path:"/textbookManage",
    icon:"#icon-shuju"
  },{
    title:"信息平台",
    path:"/information/xntz",
    icon:"#icon-gonggao"
  },
])

/*----------------钩子开始-------------------*/
onMounted(() => {
  appEntryItems.value =JSON.parse(getStorage('appEntryList'));
})


/*----------------钩子结束-------------------*/




/*------------------定义变量结束-------------------*/



/*------------------定义函数开始-------------------*/
//跳转页面
const change =(path) => {
  router.push(path)
}
/*------------------定义函数结束-------------------*/


</script>

<style scoped>
.main-container {
  width : 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.carousel-filed {
  width: 80%;
  height: 400px;
  margin-top: 60px;
  border-radius:10px;
  overflow: hidden;
}
.el-carousel__item h3 {
  color: #475669;
  font-size: 14px;
  opacity: 0.75;
  line-height: 150px;
  margin: 0;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n+1) {
  background-color: #d3dce6;
}
.carousel-img{
  width: 100%;
  height: 400px;
}

.app-filed{
  margin-top: 20px;
  width: 80%;
  animation-duration: 0.5s;
}
.app-grid-container{
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
  column-gap: 20px;
  row-gap: 20px;
}
.grid-item{
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  border-radius: 10px;
  padding-top: 20px;
  padding-bottom: 20px;
  transition: all 0.2s linear;
}
.grid-item:hover{
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
}
.grid-item .icon {
  transition: all 0.2s linear;
}
.grid-item:hover .icon {
  width: 6em;
  height: 6em;
}
.grid-item:active{
  background-color: #d4f6f5;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  transition: ease;
}
.icon{
  width: 50px;
  height: 50px;
  margin-bottom: 10px;
}
</style>
